#include <stdio.h>
#include <stdlib.h>

#define MAX_ITEMS 1000

int a[MAX_ITEMS];

inline int max (int a, int b) {
	return (a > b) ? a : b;
}

inline int cmp (const void *a, const void *b) {
	return *((int*)b) - *((int*)a);
}

int main () {    
	int l = 0, r = 0, t1 = 0, t2, n, i = 0;
    while (scanf("%d", &n) != EOF) {
		if (r > l) {
			r = 0;
			l++;
			t1 = 0;
		}
		t2 = a[r];
		a[r] = n + max (a[r], t1);
		t1 = t2;
		r++;
    }
	qsort (a, l, sizeof(int), cmp);
	printf ("%d\n", a[0]);
	return 0;
}
